﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.IO;
using System.Drawing;

namespace KTSonline.uc
{
    public partial class Supporters : System.Web.UI.UserControl
    {
        class SP
        {
            String yahoo;
            String phone;
            String name;

            public SP(String y, String p, String n)
            {
                yahoo = y;
                phone = p;
                name = n;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Collections.Generic.List<SP> lstSupporter = new System.Collections.Generic.List<SP>();
            lstSupporter.Add(new SP("graybone_online", "Lâm", "01218719731"));
            lstSupporter.Add(new SP("tdduy_khtn", "Duy", "01218719731"));
            lstSupporter.Add(new SP("tsdragon0404", "Sơn", "01218719731"));

            WebClient wc = new WebClient();
            byte[] originalData;
            MemoryStream stream;
            
            foreach (String supporter in lstSupporter)
            {
                originalData = wc.DownloadData("http://opi.yahoo.com/online?t=5&u=" + supporter);
                stream = new MemoryStream(originalData);

                Color color = (new Bitmap(stream)).GetPixel(7, 7);
                String img = "offline.png";
                if (color.R == 238 && color.G == 224 && color.B == 90)
                    img = "online.png";
            }

            MemoryStream stream = new MemoryStream(originalData);
            Bitmap bmp = new Bitmap(stream);

            Color color = (new Bitmap(stream)).GetPixel(7, 7);
            String img = "offline.png";
            if (color.R == 238 && color.G == 224 && color.B == 90)
                img = "online.png";

            Response.Write("<img src='" + img + "'/><br />");
        }
    }
}